package com.hs.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.Course;
import com.hs.mapper.CourseMapper;
import com.hs.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;
    @Override
    public Course getCourseByid(int id) {
        return courseMapper.getCourseByid(id);
    }

    @Override
    public List<Course> getCourseAll() {
        return courseMapper.getCourseAll();
    }

    @Override
    public PageInfo<Course> getCourseByPage(Course course, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> cc = courseMapper.getCourseAll();
        PageInfo<Course> pageInfo = new PageInfo<>(cc);
        return pageInfo;
    }

    @Override
    public int addCourse(Course course) {
        return courseMapper.addCourse(course);
    }

    @Override
    public int updateCourse(Course course) {
        return courseMapper.updateCourse(course);
    }

    @Override
    public int deleteCourseByid(int id) {
        return courseMapper.deleteCourseByid(id);
    }

    @Override
    public PageInfo<Course> getcourselist(Course course) {
        List<Course> getcourselist = courseMapper.getcourselist(course);
        PageInfo<Course> pageInfo = new PageInfo<>(getcourselist);
        return pageInfo;
    }

    @Override
    public PageInfo<Course> getcourselistBysort(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> gg = courseMapper.getcourselistbysort();
        PageInfo<Course> pageInfo = new PageInfo<>(gg);
        return pageInfo;
    }

    @Override
    public PageInfo<Course> getcourselistBysorta(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> gg = courseMapper.getcourselistbysorta();
        PageInfo<Course> pageInfo = new PageInfo<>(gg);
        return pageInfo;
    }

    @Override
    public PageInfo<Course> getCourseByConsultantId(int consultantId, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> getcourselist = courseMapper.getCourseByConsultantId(consultantId);
        PageInfo<Course> pageInfo = new PageInfo<>(getcourselist);
        return pageInfo;
    }

    @Override
    public PageInfo<Course> selectbypricerange(int pageNum, int pageSize, int minPrice, int maxPrice) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> cc = courseMapper.getCourseListByPriceRange(minPrice, maxPrice);
        PageInfo<Course> pageInfo = new PageInfo<>(cc);
        return pageInfo;
    }
}
